package com.ib.review.controller;

import com.ib.review.base.result.DataResult;
import com.ib.review.pojo.dto.UserLoginParam;
import com.ib.review.pojo.po.UserInfoDO;
import com.ib.review.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author ldw
 * 2024/01/24 20:16
 */
@Slf4j
@RestController
@RequestMapping("/userLogin")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @GetMapping("/verifyCode")
    public DataResult getCode() {
        return loginService.getVerifyCode();
    }

    @PostMapping("/login")
    public DataResult userLogin(@RequestBody UserLoginParam userLoginParam) {
        return loginService.userLogin(userLoginParam);
    }

    @GetMapping("/logout")
    public DataResult userLogout(@RequestParam("userAccount") String userAccount) {
        return loginService.userLogOut(userAccount);
    }

    @GetMapping("/unLockUser")
    public DataResult unLockUser(@RequestParam("userAccount") String userAccount) {
        return loginService.unLockUser(userAccount);
    }

    @PostMapping("/syncUser")
    public DataResult syncUser(@RequestBody UserInfoDO userInfo) {
        return loginService.syncUser(userInfo);
    }

    @GetMapping("/checkLogin")
    public DataResult checkLogin() {
        return loginService.checkLogin();
    }

    @PostMapping("/autoLogin")
    public DataResult autoLogin(@RequestBody Map<String, String> paramMap) {
        return loginService.autoLogin(paramMap);
    }
}
